﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SMTC.Dao.Plant;
using SMTC.Model.Domain;
using SMTC.Model.Model;
using SMTC.BO.Common;

namespace SMTC.BO.Plant
{
    public class PlantQueryServices
    {
        private PlantQueryDao _dao = new PlantQueryDao();

        /// <summary>
        /// 获取plantlist
        /// </summary>
        /// <param name="PlantName"></param>
        /// <param name="ModifyPerson"></param>
        /// <param name="starTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        public List<SMT_PlantModel> GetPlantList(string PlantName, string ModifyPerson, DateTime starTime, DateTime endTime)
        {
            PlantName = DbValueProccess.StrProccess(PlantName);
            ModifyPerson = DbValueProccess.StrProccess(ModifyPerson);
            starTime = DbValueProccess.DateTimeProccess(starTime);
            endTime = DbValueProccess.DateTimeProccess(endTime, false);

            return _dao.GetPlantList(PlantName, ModifyPerson, starTime, endTime);
        }
        /// <summary>
        /// 获取Line的单个实体
        /// </summary>
        /// <param name="LineID"></param>
        /// <returns></returns>
        public SMT_PlantModel GetPlantMode(string PlantID)
        {
            return _dao.GetPlantModel(PlantID);
        }
        /// <summary>
        /// 获取Line的Domain的list
        /// </summary>
        /// <param name="LineName"></param>
        /// <param name="LineTargetTime"></param>
        /// <param name="ModifyPerson"></param>
        /// <param name="LineCapacity"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        public List<PlantDomain> GetPlantDomainList(string PlantName, string ModifyPerson, DateTime starTime, DateTime endTime)
        {
            List<PlantDomain> domainList = new List<PlantDomain>();
            List<SMT_PlantModel> modelList = this.GetPlantList(PlantName, ModifyPerson, starTime, endTime);
            foreach (var item in modelList)
            {
                PlantDomain domain = new PlantDomain();
                domain.plant = item;
                domain.buList = _dao.GetPlantsBU(item.PlantID);
                domainList.Add(domain);
            }
            return domainList;
        }
        /// <summary>
        /// 获取Line的Domain
        /// </summary>
        /// <param name="LineID"></param>
        /// <returns></returns>
        public PlantDomain GetlineDomain(string plantID)
        {
            PlantDomain domain = new PlantDomain();
            domain.plant = this.GetPlantMode(plantID);
            domain.buList = _dao.GetPlantsBU(plantID);
            return domain;
        }
    }
}
